/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mapping;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andres
 */
@Entity
@Table(name = "solucion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Solucion.findAll", query = "SELECT s FROM Solucion s"),
    @NamedQuery(name = "Solucion.findById", query = "SELECT s FROM Solucion s WHERE s.id = :id"),
    @NamedQuery(name = "Solucion.findByCausa", query = "SELECT s FROM Solucion s WHERE s.causa = :causa"),
    @NamedQuery(name = "Solucion.findBySolucion", query = "SELECT s FROM Solucion s WHERE s.solucion = :solucion")})
public class Solucion implements Serializable {
    @JoinColumn(name = "idSla", referencedColumnName = "idSLA")
    @ManyToOne
    private Sla idSla;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "causa")
    private String causa;
    @Basic(optional = false)
    @Column(name = "solucion")
    private String solucion;
    @JoinColumn(name = "empResolvio", referencedColumnName = "idEmpleado")
    @ManyToOne
    private Empleado empResolvio;
    @OneToMany(mappedBy = "idSolucion")
    private Collection<Ticket> ticketCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSolucion")
    private Collection<ReporteSolucion> reporteSolucionCollection;

    public Solucion() {
    }

    public Solucion(Integer id) {
        this.id = id;
    }

    public Solucion(Integer id, String causa, String solucion) {
        this.id = id;
        this.causa = causa;
        this.solucion = solucion;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCausa() {
        return causa;
    }

    public void setCausa(String causa) {
        this.causa = causa;
    }

    public String getSolucion() {
        return solucion;
    }

    public void setSolucion(String solucion) {
        this.solucion = solucion;
    }

    public Empleado getEmpResolvio() {
        return empResolvio;
    }

    public void setEmpResolvio(Empleado empResolvio) {
        this.empResolvio = empResolvio;
    }

    @XmlTransient
    public Collection<Ticket> getTicketCollection() {
        return ticketCollection;
    }

    public void setTicketCollection(Collection<Ticket> ticketCollection) {
        this.ticketCollection = ticketCollection;
    }

    @XmlTransient
    public Collection<ReporteSolucion> getReporteSolucionCollection() {
        return reporteSolucionCollection;
    }

    public void setReporteSolucionCollection(Collection<ReporteSolucion> reporteSolucionCollection) {
        this.reporteSolucionCollection = reporteSolucionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Solucion)) {
            return false;
        }
        Solucion other = (Solucion) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mapping.Solucion[ id=" + id + " ]";
    }

    public Sla getIdSla() {
        return idSla;
    }

    public void setIdSla(Sla idSla) {
        this.idSla = idSla;
    }
    
}
